package com.nikitova.craps3d.model
{
	import com.carlcalderon.arthropod.Debug;
	import com.foomonger.utils.Later;

	import org.puremvc.as3.multicore.interfaces.IProxy;
	import org.puremvc.as3.multicore.patterns.proxy.Proxy;
	import org.puremvc.as3.multicore.utilities.startupmanager.model.StartupResourceProxy;

	/**
	 * @author schranz
	 */
	public class EntityProxy extends Proxy implements IProxy 
	{
		private static var _delay : uint = 0;
		private static var DEBUG : Boolean = false;
		
		public function EntityProxy(proxyName:String)
		{
			super(proxyName);
		}

		protected function sendLoadedNotification( noteName:String, noteBody:String, srName:String ):void 
		{
			var srProxy:StartupResourceProxy = facade.retrieveProxy(srName) as StartupResourceProxy;
			if ( !srProxy.isTimedOut() )
			{
				if (DEBUG)
				{
					
					// *** simulate an async loading delay
					Later.call(sendNotification, _delay, false, noteName, noteBody);
					_delay += 25;
				}
				else
				{
					sendNotification(noteName, noteBody);
				}
			}
		}
	}
}
